//
//  UILabel-Ex.swift
//  weibo1990
//
//  Created by 曹晓龙 on 15/10/17.
//  Copyright © 2015年 曹晓龙. All rights reserved.
//

import UIKit

extension UILabel {
    
    ///  便利构造函数
    ///
    ///  - parameter titleText: 文字内容
    ///  - parameter textFont:  字号
    ///  - parameter color:     字体颜色--默认深黑色
    ///  - screenInset : 两侧缩进
    ///
    ///  - returns: UILabel
    convenience init(titleText:String, textFont:CGFloat, color:UIColor = UIColor.darkGrayColor(), screenInset:CGFloat = 0){
        
        self.init()
        
        text = titleText
        
        font = UIFont.systemFontOfSize(textFont)
        
        textColor = color
        
        numberOfLines = 0
        
        if screenInset == 0 {
            
            textAlignment = NSTextAlignment.Center
        } else {
            
            preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.width - 2 * screenInset
            textAlignment = NSTextAlignment.Left
        }
        
        
        sizeToFit()
    }
}